package com.diaohw.module.log.obj.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.diaohw.platform.framework.db.obj.BaseModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDateTime;

/**
 * <p>
 * SQL执行日志
 * </p>
 *
 * @author D-Hw
 * @since 2024-07-08
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("DB_LOG")
@Schema(name = "DbLog", description = "SQL执行日志")
public class DbLog extends BaseModel<DbLog> {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 服务名称
     */
    @Schema(description = "服务名称")
    @TableField("APPLICATION_NAME")
    private String applicationName;

    /**
     * 服务IP
     */
    @Schema(description = "服务IP")
    @TableField("APPLICATION_IP")
    private String applicationIp;

    /**
     * 请求ID
     */
    @Schema(description = "请求ID")
    @TableField("REQUEST_ID")
    private String requestId;

    /**
     * 链路编号
     */
    @Schema(description = "链路编号")
    @TableField("LINK_ID")
    private Integer linkId;

    /**
     * 登录用户ID
     */
    @Schema(description = "登录用户ID")
    @TableField("LOGIN_ID")
    private String loginId;

    /**
     * 登录用户名称
     */
    @Schema(description = "登录用户名称")
    @TableField("LOGIN_USERNAME")
    private String loginUsername;

    /**
     * 登录用户昵称
     */
    @Schema(description = "登录用户昵称")
    @TableField("LOGIN_NICKNAME")
    private String loginNickname;

    /**
     * 请求执行状态
     */
    @Schema(description = "请求执行状态")
    @TableField("STATUS")
    private String status;

    /**
     * 错误异常
     */
    @Schema(description = "错误异常")
    @TableField("MSG")
    private String msg;


    /**
     * SQL 类型
     */
    @Schema(description = "SQL 类型")
    @TableField("SQL_TYPE")
    private String sqlType;

    /**
     * SQL 模板
     */
    @Schema(description = "SQL 模板")
    @TableField("SQL_TEMPLATE")
    private String sqlTemplate;

    /**
     * SQL 参数
     */
    @Schema(description = "SQL 参数")
    @TableField("SQL_PARAMETER")
    private String sqlParameter;

    /**
     * SQL 语句，真正执行的SQL
     */
    @Schema(description = "SQL 语句，真正执行的SQL")
    @TableField("SQL_CONTENT")
    private String sqlContent;

    /**
     * SQL语句执行影响行数
     */
    @Schema(description = "SQL语句执行影响行数")
    @TableField("SQL_ROW_COUNT")
    private Integer sqlRowCount;

    /**
     * SQL执行状态
     */
    @Schema(description = "SQL执行状态")
    @TableField("SQL_RESULT")
    private Byte sqlResult;

    /**
     * 请求时间
     */
    @Schema(description = "请求时间")
    @TableField("REQUEST_TIME")
    private LocalDateTime requestTime;

    /**
     * 响应时间
     */
    @Schema(description = "响应时间")
    @TableField("RESPONSE_TIME")
    private LocalDateTime responseTime;

    /**
     * 消耗时间（毫秒）
     */
    @Schema(description = "消耗时间（毫秒）")
    @TableField("ELAPSED")
    private Double elapsed;

}
